package com.tangsm.api.demo.enums;

import org.springframework.http.HttpStatus;

/**
 * API通用状态码枚举类
 *
 * @author 湯神码
 */
public enum ResultStatus {
    /** 成功 **/
    SUCCESS(HttpStatus.OK, 200, "OK"),
    /** 错误的请求 **/
    BAD_REQUEST(HttpStatus.BAD_REQUEST, 400, "Bad Request"),
    /** 内部服务器错误 **/
    INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "Internal Server Error"),;

    /** 返回的HTTP状态码,  符合http请求 */
    private HttpStatus httpStatus;
    /** 业务异常码 */
    private Integer code;
    /** 业务异常信息描述 */
    private String message;

    ResultStatus(HttpStatus httpStatus, Integer code, String message) {
        this.httpStatus = httpStatus;
        this.code = code;
        this.message = message;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "ResultStatus{" +
                "httpStatus=" + httpStatus +
                ", code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}